<%-- 
    Document   : homePage
    Created on : 19-feb-2011, 20:51:06
    Author     : Alexandre
--%>

<%@page import="model.Message"%>
<%@page import="model.GroupDefinition"%>
<%@page import="model.User"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %> 
<!doctype html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <title>SocialBill Home Page</title>
    </head>
    <% User myself = null; %>
    <body>
        <%
                         if (session != null) {
                myself = (User) session.getAttribute("user");
                if (myself == null) {
                    response.sendRedirect("index.jsp");
                    return;
                }
            } else {
                response.sendRedirect("index.jsp");
                return;
            }
        %>
        <div id="groupList">
            Mis grupos
            <ul>


                <%
            
                if(myself.getGroupDefinitionCollection() != null){
                    for(GroupDefinition group : myself.getGroupDefinitionCollection()){ %>
                <li> <a href ="Controller?action=showgroup&groupId=<%=group.getIdgroup()%>> <%= group.getName()%></a> </li>  
                <%}
            }
                %>
            </ul>
            <div id="newGroup">
                <form action="Controller" method="POST">
                    <input type="hidden" name="action" value="newgroup"/>
                    <input type="text" name="group" value="New Group!" />
                    <input type="submit" value="Create" />
                </form>
            </div>
            <div id="joinGroup">
                <form action="Controller" method="POST">
                    <input type="hidden" name="action" value="joingroup"/>
                    <input type="text" name="idgroup" value="0000" />
                    <input type="password" name="passwordgroup" value="" />
                    <input type="submit" value="Join!" />
                </form>  
            </div>

        </div>
        <div id="notificationList">

        </div>
        <div id="messageList">
            <%
           if(myself.getMessageCollection() != null){
               for(Message msg : myself.getMessageCollection()){ %>
            <li> <%= msg.getTitle()%> </li>  
            <%}
                }
            %>
        </div>
    </body>
</html>
